<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/WEB-INF/templates/BasicTemplate.xhtml">

	<ui:define name="content">
		<f:event type="preRenderView"
			listener="#{interviewController.beforeSearch}" />
		<div class="title ui-widget-header ui-corner-all">
			<h:panelGrid style="margin:auto;">
		BUSCAR ENTREVISTAS
		</h:panelGrid>

		</div>
		<h:form id="formSearch">
			<h:panelGrid style="margin:auto;">

				<h:panelGrid style="margin:auto;text-align:center;">
					<p:messages id="messages"></p:messages>
				</h:panelGrid>
				

					<h:panelGrid columns="6">
						<p:outputLabel value="N° de documento"></p:outputLabel>
						<p:inputText style="width: 180px;"
							value="#{interviewController.candidateDocumentNumberSearch}"></p:inputText>
						<p:outputLabel value="Nombres"></p:outputLabel>
						<p:inputText style="width: 180px;"
							value="#{interviewController.candidateFirstnameSearch}"></p:inputText>
						<p:outputLabel value="Apellidos"></p:outputLabel>
						<p:inputText style="width: 180px;"
							value="#{interviewController.candidateLastnameSearch}"></p:inputText>
							
						<p:outputLabel value="Area"></p:outputLabel>
					<p:selectOneMenu id="areas"
						value="#{interviewController.areaSelected}">
						<f:selectItem itemValue="0" itemLabel="Todos"></f:selectItem>
						<f:selectItems value="#{interviewController.areas}"></f:selectItems>
						<p:ajax listener="#{interviewController.searchSubAreas}"
							update=":formSearch:subAreas :formSearch:messages"></p:ajax>
					</p:selectOneMenu>
					<p:outputLabel value="Subarea"></p:outputLabel>
					<p:selectOneMenu id="subAreas"
						value="#{interviewController.subAreaSelected}">
						<f:selectItem itemValue="0" itemLabel="Todos"></f:selectItem>
						<f:selectItems value="#{interviewController.subAreas}"></f:selectItems>
					</p:selectOneMenu>	

						
						<p:outputLabel value="Reclutador"></p:outputLabel>
						<p:selectOneMenu id="recruitments"
							value="#{interviewController.recruiterSelected}">
							<f:selectItem itemValue="0" itemLabel="Todos"></f:selectItem>
							<f:selectItems value="#{interviewController.recruiters}"></f:selectItems>
						</p:selectOneMenu>
						
						<p:outputLabel value="Fecha de entrevista"></p:outputLabel>
						<p:calendar value="#{interviewController.interviewedAtSearch}"></p:calendar>
						

						<p:outputLabel value="Estado"></p:outputLabel>
						<p:selectOneMenu id="states"
							value="#{interviewController.stateSelected}">
							<f:selectItem itemValue="0" itemLabel="Todos"></f:selectItem>
							<f:selectItems value="#{interviewController.states}"></f:selectItems>
						</p:selectOneMenu>
						
					</h:panelGrid>
					
				<h:panelGrid style="margin:auto;text-align:center;" columns="3">
					<p:commandButton icon="ui-icon-search"
						actionListener="#{interviewController.search}" value="Buscar"
						process="@form"
						update=":formSearch:searchTable :formSearch:messages :formSearch:interviewId :formSearch:editButtom">
					</p:commandButton>

				</h:panelGrid>
			</h:panelGrid>

			<h:panelGrid columns="2">
				
				<p:commandButton id="editButtom" action="edit_interview.xhtml"
					icon="ui-icon-pencil" value="Editar"
					disabled="#{interviewController.interviewSelected==null}">
					<f:param name="interviewId"
						value="#{interviewController.interviewSelected.id}"></f:param>
				</p:commandButton>
				<p:outputLabel id="interviewId"
					value="Entrevista seleccionada: #{interviewController.interviewSelected!=null?interviewController.interviewSelected.id:''}">
				</p:outputLabel>
			</h:panelGrid>

			<p:dataTable value="#{interviewController.interviews}" var="i"
				rowKey="#{i.id}" paginator="true" rows="10" id="searchTable"
				selectionMode="single"
				selection="#{interviewController.interviewSelected}">

				<p:ajax event="rowSelect"
					update=":formSearch:interviewId :formSearch:editButtom" />
				<p:ajax event="rowUnselect"
					update=":formSearch:interviewId :formSearch:editButtom" />

				<p:column headerText="ID" sortBy="#{i.id}">
					<h:outputText value="#{i.id}"></h:outputText>
				</p:column>

				<p:column headerText="N° de documento"
					sortBy="#{i.candidate.documentNumber}">
					<h:outputText value="#{i.candidate.documentNumber}"></h:outputText>
				</p:column>

				<p:column headerText="Nombres" sortBy="#{i.candidate.firstname}">
					<h:outputText value="#{i.candidate.firstname}"></h:outputText>
				</p:column>

				<p:column headerText="Apellidos" sortBy="#{i.candidate.lastname}">
					<h:outputText value="#{i.candidate.lastname}"></h:outputText>
				</p:column>
				
				<p:column headerText="Area" sortBy="#{i.candidate.area.area.name}">
					<h:outputText value="#{i.candidate.area.area.name}"></h:outputText>
				</p:column>

				<p:column headerText="Subarea" sortBy="#{i.candidate.area.name}">
					<h:outputText value="#{i.candidate.area.name}"></h:outputText>
				</p:column>
				
				<p:column headerText="Estado" sortBy="#{i.interviewState.name}">
					<h:outputText value="#{i.interviewState.name}"></h:outputText>
				</p:column>

				<p:column headerText="Entrevista" width="120"
					sortBy="#{i.interviewedAt}">
					<h:outputText value="#{i.interviewedAt}">
						<f:convertDateTime pattern="dd-MM-yyyy hh:mm:ss a" />
					</h:outputText>
				</p:column>
				
				<p:column headerText="Comentarios" sortBy="#{i.comment}">
					<h:outputText value="#{i.comment}"></h:outputText>
				</p:column>
				
				<p:column headerText="Fecha creacion" width="120"
					sortBy="#{i.createdAt}">
					<h:outputText value="#{i.createdAt}">
						<f:convertDateTime pattern="dd-MM-yyyy hh:mm:ss a" />
					</h:outputText>
				</p:column>

				<p:column headerText="Reclutador"
					sortBy="#{i.recruiter.firstname} #{i.recruiter.lastname}">
					<h:outputText
						value="#{i.recruiter.firstname} #{i.recruiter.lastname}"></h:outputText>
				</p:column>


				

			</p:dataTable>


		</h:form>
	</ui:define>

</ui:composition>
</html>
